<template>
  <div class="page" style="margin-top: 5px">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="page.currentPage"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="page.pageSize"
      background
      layout="prev, pager, next"
      :total="total"></el-pagination>
  </div>
</template>

<script>
export default {
  props: ["total"],
  data() {
    return {
      // 页码参数
      page: {
        currentPage: 1,
        pageSize: 15
      }
    };
  },
  methods: {
    handleSizeChange(val) {
      this.page.pageSize = val;
      this.currentPage = 1
      // console.log(`每页 ${this.page.pageSize} 条`);
      this.$emit("pageChange", this.page);
    },
    handleCurrentChange(val) {
      this.page.currentPage = val;
      // console.log(`当前页: ${this.page.currentPage}`);
      this.$emit("pageChange", this.page);
    }
  }
};
</script>

<style lang="less">
</style>
